package com.fire.modules.sys.controller;

import java.util.List;
import java.util.Map;

import com.fire.common.utils.PageUtils;
import com.fire.common.utils.Query;
import com.fire.common.utils.R;
import com.fire.modules.entity.TbUser;
import com.fire.modules.sys.service.SysTbUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 普通用户
 * 
 * @author lanyonglin
 * @email www.baidu.com
 * @date 2018-05-24 14:39:17
 */
@RestController
@RequestMapping("/sys/tbUser")
public class SysTbUserController {
	@Autowired
	private SysTbUserService userService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("tbUser:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);
		List<TbUser> userList = userService.queryList(query);
		int total = userService.queryTotal(query);
		PageUtils pageUtil = new PageUtils(userList, total, query.getLimit(), query.getPage());
		return R.ok().put("page", pageUtil);
	}
	
	
//	/**
//	 * 信息
//	 */
//	@RequestMapping("/info/{userId}")
//	@RequiresPermissions("user:info")
//	public R info(@PathVariable("userId") Integer userId){
//		TbUser tbUser = new TbUser();
//		tbUser.setUserId((long)userId);
//		TbUser user = userService.queryObject(tbUser);
//		return R.ok().put("user", user);
//	}
	
//	/**
//	 * 保存
//	 */
//	@RequestMapping("/save")
//	@RequiresPermissions("user:save")
//	public R save(@RequestBody TbUser user){
//		userService.save(user);
//
//		return R.ok();
//	}
	
//	/**
//	 * 修改
//	 */
//	@RequestMapping("/update")
//	@RequiresPermissions("user:update")
//	public R update(@RequestBody UserEntity user){
//		userService.update(user);
//
//		return R.ok();
//	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("tbUser:delete")
	public R delete(@RequestBody Long[] userIds){
		userService.deleteBatch(userIds);
		return R.ok();
	}
	
}
